package com.zfzs.post.controller;

import com.zfzs.post.aop.log.Log;
import com.zfzs.post.common.bean.ResponseResult;
import com.zfzs.post.model.dto.QueryTerAvgTransactionDTO;
import com.zfzs.post.model.vo.transaction.TerAvgTransactionVO;
import com.zfzs.post.model.vo.transaction.TerSumTransactionVO;
import com.zfzs.post.service.TransactionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wq
 * @date 2019/10/16 16:49
 * @description
 */
@RestController
@RequestMapping("transaction/")
public class TransactionController {


    @Autowired
    private TransactionService transactionService;

    /**
     * 台均交易
     *
     * @param dto
     * @return
     */
    @PostMapping("get_avg_tran")
    @Log("台均交易")
    public ResponseResult findTerAvgTransaction(@RequestBody QueryTerAvgTransactionDTO dto) {
        List<TerAvgTransactionVO> list = transactionService.findTerAvgTransaction(dto);
        return ResponseResult.ok(new HashMap<String, Object>() {{
            put("list", list);
        }});
    }


    /**
     * 总交易额
     *
     * @param dto
     * @return
     */
    @PostMapping("get_sum_tran")
    @Log("总交易额")
    public ResponseResult findTerSumTransaction(@RequestBody QueryTerAvgTransactionDTO dto) {
        List<TerSumTransactionVO> list = transactionService.findTerSumTransaction(dto);
        return ResponseResult.ok(new HashMap<String, Object>() {{
            put("list", list);
        }});
    }

    /**
     * 交易统计
     *
     * @param params
     * @return
     */
    @PostMapping("get_tran_statistics")
    @Log("交易统计")
    public ResponseResult getTranStatistics(@RequestBody Map<String, String> params) {
        Map<String, Object> map = transactionService.findTranStatistics(params);
        return ResponseResult.ok(map);
    }

    /**
     * 交易统计
     *
     * @param params
     * @return
     */
    @PostMapping("get_tran_sum_statistics")
    @Log("交易统计")
    public ResponseResult getTranSumStatistics(@RequestBody Map<String, String> params) {
        Map<String, Object> map = transactionService.getTranSumStatistics(params);
        return ResponseResult.ok(map);
    }


}
